 <template>
 <el-form :model="form" label-width="120px">
   <el-tabs type="border-card" class="demo-tabs">
      <el-tab-pane>
        <template #label>
          <span class="custom-tabs-label">
            <el-icon><calendar /></el-icon>
            <span>基础</span>
          </span>
        </template> 
            <JmInput  jmname="标题" v-model="form.title"   type="text"  ></JmInput>
            <JmInput  jmname="作者" v-model="form.author"   type="text"  ></JmInput>
            <JmInput  jmname="标记" v-model="form.flag"   type="text"  ></JmInput>
            <JmInput  jmname="链接" v-model="form.art_link"   type="text"  ></JmInput>

           <JmEnum jmname="推荐" v-model="form.is_recommend" :jv="{1: '是', 0: '否'}" jtype="2"  ></JmEnum>
           <JmEnum jmname="最新" v-model="form.is_news" :jv="{1: '是', 0: '否'}" jtype="2"  ></JmEnum>
           
           <JmEnum jmname="栏目id" v-model="form.cate_id" :jv="cate" jtype="4"  ></JmEnum>
<!--        

parent_path  
delete_time
create_time
update_time  
 
   --> 

      </el-tab-pane>



      <el-tab-pane label="图片">
       
           <JmInput type="img" jmname="缩略图" v-model="form.art_img"></JmInput> 
           <JmInput type="img" jmname="大图" v-model="form.art_img_big"></JmInput> 
           <JmInput type="img" jmname="组图" v-model="form.art_img_more"></JmInput>  
  


      </el-tab-pane>

      <el-tab-pane label="seo">
        <JmInput  jmname="seo标题"  v-model="form.seo" ></JmInput>

        <JmInput jmname="关键词"  v-model="form.keywords"   type="textarea"   ></JmInput>

        <JmInput jmname="seo描述"  v-model="form.description"   type="textarea" ></JmInput>
  
      </el-tab-pane>
      
      
      <el-tab-pane label="内容">
         
            <JmInput type="textarea" jmname="摘要" v-model="form.abstract"></JmInput>
            <JmInput type="textarea" jmname="内容" v-model="form.content"></JmInput>
  
      </el-tab-pane>
      
   

      <el-form-item>
        <el-button type="primary" @click="onSubmit">Create</el-button> 
      </el-form-item>
    </el-tabs>
            
 
  </el-form>
</template>
 
<script>
import JmInput from "../../../components/form/JmInput.vue";
import JmEnum from "../../../components/form/JmEnum.vue";
export default {
  components: { JmInput, JmEnum },
  data() {
    return {
         form: { 
              cate_id:0,
              parent_path:'',
              title:'',
              author:'',
              abstract:'',
              content:'',
              art_link:'',
              art_img_big:'',
              art_img:'',
              art_img_more:'',
              flag:'',
              views:0,
              seo:'',
              keywords:'',
              description:'简介',
              is_recommend:1, 
              is_news:1,  
 
            },

      cate :{}
    };
  },

//在export default中添加即可不用管顺序
    watch: {
       //监听内容
       edit_id() {
        console.log("edit_id发生了变化");
        this.getDataList();
      }
    },
    props: ['edit_id'],
     inject:['handleClose'],
     
  mounted() {
    this.getDataList();
  },
  methods: {
    // 配置信息列表初始化
    async getDataList() {
      try {
          const res = await this.$api.Cate({select:1,cate_model:3}); 
          let ccc={}; 
          res.rows.forEach(element => { 
                ccc[element.id]=element.prefix+element.cate_name;
          }); 
          console.log(ccc,"查询")
          this.cate=ccc; 

 
   /*查看单条数据*/
        const find = await this.$api.getArticleFind({ids:this.edit_id}); 
        
           this.form.cate_id=find.cate_id;
            this.form.parent_path=find.parent_path;
              this.form.title=find.title;
              this.form.author=find.author;
              this.form.abstract=find.abstract;
              this.form.content=find.content;
              this.form.art_link=find.art_link;
              this.form.art_img_big=find.art_img_big;
              this.form.art_img=find.art_img;
              this.form.art_img_more=find.art_img_more;
              this.form.flag=find.flag;
              this.form.views=find.views;
              this.form.seo=find.seo;
              this.form.keywords=find.keywords;
              this.form.description=find.description;
              this.form.is_recommend=find.is_recommend;
              this.form.is_news=find.is_news; 
        
      } catch (error) {
        /*console.error(error);*/
      }
    },
     async onSubmit() {
       const find =  await this.$api.editArticle(this.form,this.edit_id);  
     
       this.$parent.$parent.$parent.$parent.handleClose();
            //  this.$parent.handleClose();
            // this.$emit("handleClose","如果需要传值，参数写在这里"); 
    },
  },
};
 
</script>